﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:c2iGMailNotifier="clr-namespace:c2iGMailNotifier"
    mc:Ignorable="d" xmlns:c2iGMailNotifier_Converter="clr-namespace:c2iGMailNotifier.Converter" x:Class="c2iGMailNotifier.View.OptionsView"
    DataContext="{Binding Source={x:Static c2iGMailNotifier:Locator.OptionsViewModelStatic}}"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:controls="clr-namespace:c2iGMailNotifier.Controls" >
    <UserControl.Resources>
        <c2iGMailNotifier_Converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    </UserControl.Resources>
    <Border Background="{DynamicResource MainBackgroundBrush}" BorderThickness="1" BorderBrush="Black">
        <ScrollViewer Margin="4" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Border  Background="{DynamicResource MainBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5" Padding="5">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>

                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="User Name" Margin="4"/>
                        <TextBox Margin="4,0" VerticalAlignment="Center" Grid.Column="1"  Text="{Binding User.UserName}" Grid.ColumnSpan="2" Height="21.96" />

                        <TextBlock Text="Password" Grid.Row="1" Margin="4"/>
                        <PasswordBox 
                            controls:PasswordHelper.Attach="True" 
                            Grid.Column="1"
                            Grid.Row="1"  
                            VerticalAlignment="Center"
                            Margin="4,0"
                            controls:PasswordHelper.Password="{Binding User.Password, Mode=TwoWay}" Grid.ColumnSpan="2" Height="19.8" />

                        <TextBlock Text="Refresh every" Grid.Row="2" Margin="4"/>
                        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="4,0" Grid.ColumnSpan="2" Height="23.96">
                            <ComboBox SelectedItem="{Binding User.RefreshInterval}" Width="50">
                                <sys:Int32>1</sys:Int32>
                                <sys:Int32>5</sys:Int32>
                                <sys:Int32>15</sys:Int32>
                                <sys:Int32>30</sys:Int32>
                                <sys:Int32>60</sys:Int32>
                            </ComboBox>

                            <TextBlock Text="mn" VerticalAlignment="Center" Margin="4"/>
                        </StackPanel>

                        <TextBlock VerticalAlignment="Center" Text="Notification sound" Grid.Row="3 " Margin="4"/>

                        <TextBlock Grid.Row="3" Grid.Column="1" FontStyle="Italic"  Text="{Binding User.NotificationSoundFileName, Mode=TwoWay}" TextWrapping="NoWrap" VerticalAlignment="Center" x:Name="txtNotificationSoundFileName"/>
                        <Button Grid.Row="3" Grid.Column="2" Content="..."  Width="24" Click="btnChooseFileName_Click" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="4"/>

                        <Button Command="{Binding SaveSettingsCommand}" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0" Style="{StaticResource toolbarButtonStyle}" ToolTip="Save settings" Grid.ColumnSpan="2" Height="40" Width="60">
                            <Image Source="/c2iGMailNotifier;Component/Images/Save48.png" Width="32"/>
                        </Button>

                    </Grid>
                </Border>
                <Border  Background="{DynamicResource MainBackgroundBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5" Padding="5" Margin="0,5,0,10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto"  />
                            <RowDefinition Height="Auto"  />
                            <RowDefinition Height="Auto"  />
                            <RowDefinition Height="*"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.5*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="0.5*" />
                        </Grid.ColumnDefinitions>
                        <StackPanel HorizontalAlignment="Center">
                            <TextBlock Text="Local version" Grid.Row="0" Margin="4"  HorizontalAlignment="Center"/>
                            <TextBlock Text="{Binding Version}" Margin="4"  HorizontalAlignment="Center"/>
                        </StackPanel>

                        <Button 
                            Command="{Binding CheckVersionCommand}"
                            Grid.Column="1"
                            Margin="4"
                            VerticalAlignment="Bottom"
                            Style="{StaticResource toolbarButtonStyle}" 
                            ToolTip="Check updates">
                            <Image Source="/c2iGMailNotifier;Component/Images/Update48.png" Width="32"/>
                        </Button>

                        <StackPanel HorizontalAlignment="Center" Grid.Column="2">
                            <TextBlock Text="Server version" Grid.Row="0" Margin="4"  HorizontalAlignment="Center"/>
                            <TextBlock Text="{Binding c2iGmailNotifierInformation.Version}" Margin="4"  HorizontalAlignment="Center"/>
                        </StackPanel>


                        <TextBlock 
                            Grid.Row="2"
                            Margin="4" 
                            Grid.ColumnSpan="3" 
                            TextWrapping="Wrap" 
                            Foreground="Red" Text="A new version is available on our web site!" 
                            HorizontalAlignment="Center" 
                            FontWeight="Bold"
                            Visibility="{Binding IsNewVersionAvailable, Converter={StaticResource BoolToVisibilityConverter}, Mode=Default}" />

                        <TextBlock 
                            Grid.Row="3"
                            Grid.ColumnSpan="3" 
                            TextWrapping="Wrap" 
                            Text="{Binding c2iGmailNotifierInformation.Description}" 
                            Visibility="{Binding IsNewVersionAvailable, Converter={StaticResource BoolToVisibilityConverter}, Mode=Default}"
                            HorizontalAlignment="Left"
                            Margin="4" />


                        <Button 
							HorizontalAlignment="Center" 
							VerticalAlignment="Center" 
							Content="Go to web site" 
							Template="{DynamicResource HyperlinkButtonTemplate}" 
							Command="{Binding NavigateCommand, Mode=Default}" 
							CommandParameter="{Binding c2iGmailNotifierInformation.Url, Mode=Default}" 
							Grid.ColumnSpan="3" 
							Grid.Row="4" 
							Visibility="{Binding IsNewVersionAvailable, Converter={StaticResource BoolToVisibilityConverter}, Mode=Default}" 
							Style="{DynamicResource HyperlinkStyle}"/>



                        <Button 
                            Grid.Row="5"
                            Grid.Column="2"
                            Margin="4"
                            VerticalAlignment="Bottom"
                            Style="{StaticResource toolbarButtonStyle}" 
                            ToolTip="About" HorizontalAlignment="Right" Click="Button_Click">
                            <Image Source="/c2iGMailNotifier;Component/Images/Info.png" Width="32"/>
                        </Button>
                        <TextBlock Grid.ColumnSpan="2" Grid.Row="5" Text="c2i-GMailNotifier was developed by Richard Clark." TextWrapping="Wrap" VerticalAlignment="Bottom"/>

                    </Grid>
                </Border>
            </StackPanel>
        </ScrollViewer>
    </Border>
</UserControl>
